function fn (){
    $.ajax({
        url : '/my/user/userinfo',
        success : function(ele){
            console.log(ele);
            // 设置昵称
            var name = ele.data.nickname || ele.data.username;
            $('.user-info').text(name);
            //更改头像
            if(ele.data.user_pic){
                $(".layui-nav-img").attr('src',ele.data.user_pic).show();
            }else{
                var fister = name.substr(0,1).toUpperCase();
                $('.user-touxiang').text(fister).css('display','inline-block');
            }
        },
        headers : {
            'Authorization': localStorage.getItem('token'),
        },

    })

}
fn();

//---------------------退出````````````````````````````````````````````


$('.user-out').on('click',function(e){
    e.preventDefault();
    //点击后清空本地并返回到login页面
    localStorage.removeItem('token');
    location.href = './login.html';
})
